﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using System.Xml.Serialization;
using WXY.Course.Model;

namespace WXY.Course.Web.Controllers
{
    public class LeaderController : Controller
    {
        public ActionResult Detail()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(LeaderInfo));
            string path = Server.MapPath("~/Leader.xml");
            LeaderInfo leader = null;
            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                using (StreamReader sr = new StreamReader(fs, Encoding.UTF8))
                {
                    //string xmlContent = sr.ReadToEnd();
                    leader = serializer.Deserialize(sr) as LeaderInfo;
                }
            }

            if (leader == null)
            {
                return Content("no leader exists");
            }

            return View(leader);
        }
    }
}
